﻿#------------------------------------------------------------------
#add_platform.cmake
#please dont modify this cmake
#2018年6月17日 12点32分
#------------------------------------------------------------------
#用户需要手动设置CSYS变量为目标平台的值。
SET(CSYS "Windows" CACHE STRING "Target platform name, add_platform.cmake")
SET(CSYS_PRIVATE ${CSYS} CACHE INTERNAL "CSYS_PRIVATE")

IF(${CSYS_PRIVATE} STREQUAL Embedded)
    ADD_DEFINITIONS(-D__EMBEDDED_LINUX__)
ELSEIF(${CSYS_PRIVATE} STREQUAL Arm32)
    ADD_DEFINITIONS(-D__EMBEDDED_LINUX__)
    ADD_DEFINITIONS(-D__ARM_LINUX__)
ELSEIF(${CSYS_PRIVATE} STREQUAL Mips32)
    ADD_DEFINITIONS(-D__EMBEDDED_LINUX__)
    ADD_DEFINITIONS(-D__MIPS_LINUX__)
ELSEIF(${CSYS_PRIVATE} STREQUAL Linux)
    ADD_DEFINITIONS(-D__LINUX__)
    ADD_DEFINITIONS(-D__LINUX32__)
ELSEIF(${CSYS_PRIVATE} STREQUAL Linux64)
    ADD_DEFINITIONS(-D__LINUX__)
    ADD_DEFINITIONS(-D__LINUX64__)

ELSEIF(${CSYS_PRIVATE} STREQUAL Win32)
    ADD_DEFINITIONS(-D__WIN__)
    ADD_DEFINITIONS(-D__WIN32__)
ELSEIF(${CSYS_PRIVATE} STREQUAL Windows)
    ADD_DEFINITIONS(-D__WIN__)
    ADD_DEFINITIONS(-D__WIN32__)
ELSEIF(${CSYS_PRIVATE} STREQUAL Win64)
    ADD_DEFINITIONS(-D__WIN__)
    ADD_DEFINITIONS(-D__WIN64__)
ELSEIF(${CSYS_PRIVATE} STREQUAL WinRT)
    ADD_DEFINITIONS(-D__WIN__)
    ADD_DEFINITIONS(-D__WINRT__)
ELSEIF(${CSYS_PRIVATE} STREQUAL MSVC32)
    ADD_DEFINITIONS(-D__WIN__)
    ADD_DEFINITIONS(-D__WIN32__)
    ADD_DEFINITIONS(-D__MSVC__)
    ADD_DEFINITIONS(-D__MSVC32__)
ELSEIF(${CSYS_PRIVATE} STREQUAL MSVC)
    ADD_DEFINITIONS(-D__WIN__)
    ADD_DEFINITIONS(-D__WIN32__)
    ADD_DEFINITIONS(-D__MSVC__)
    ADD_DEFINITIONS(-D__MSVC32__)
ELSEIF(${CSYS_PRIVATE} STREQUAL MSVC64)
    ADD_DEFINITIONS(-D__WIN__)
    ADD_DEFINITIONS(-D__WIN64__)
    ADD_DEFINITIONS(-D__MSVC__)
    ADD_DEFINITIONS(-D__MSVC64__)

ELSEIF(${CSYS_PRIVATE} STREQUAL macOS)
    ADD_DEFINITIONS(-D__DARWIN__)
ELSEIF(${CSYS_PRIVATE} STREQUAL iOS)
    ADD_DEFINITIONS(-D__IOS__)
ELSEIF(${CSYS_PRIVATE} STREQUAL iOSSimulator)
    ADD_DEFINITIONS(-D__IOS__)

ELSEIF(${CSYS_PRIVATE} STREQUAL Android)
    ADD_DEFINITIONS(-D__ANDROID__)
ELSEIF(${CSYS_PRIVATE} STREQUAL AndroidX86)
    ADD_DEFINITIONS(-D__ANDROIDX86__)

ENDIF()

#编译类型
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Build Type, add_platform.cmake")
SET(BUILD ${CMAKE_BUILD_TYPE} CACHE INTERNAL "BUILD")
IF(NOT BUILD)
    SET(BUILD Release CACHE INTERNAL "BUILD")
ENDIF()

SET(CSYS_STD_DIR ${CSYS_PRIVATE} CACHE INTERNAL "CSYS_STD_DIR")
SET(CAPP_STD_DIR ${CSYS_PRIVATE} CACHE INTERNAL "CAPP_STD_DIR")

message(add_platform.cmake)
message("Build ${CMAKE_PROJECT_NAME} to ${CSYS_PRIVATE} (CSYS=${CSYS_PRIVATE} is configed in cmake project configure page.)" )
message("Build ${CMAKE_PROJECT_NAME} at ${CSYS_STD_DIR} (App deploy, add Sdk=${CSYS_PRIVATE})" )
message("Build ${CMAKE_PROJECT_NAME} on ${CMAKE_HOST_SYSTEM_NAME} (Operating System=${CMAKE_HOST_SYSTEM_NAME})" )
IF(NOT CSYS_PRIVATE)
    message("Build ${CMAKE_PROJECT_NAME} Target platform is decided by cmake variable CSYS. Please set it." )
ENDIF()

IF(NOT CSYS_PRIVATE)
    message("cmake variable CSYS is required! pleace check add_platform.cmake")
    message(FATAL_ERROR "error occured! please check build output panel.")
ENDIF()

ADD_DEFINITIONS(-DC_SYS_NAME=${CSYS_PRIVATE})
ADD_DEFINITIONS(-DC_BUILD_TYPE=${BUILD})

#兼容qmake版multi-link
#源代码里面用的宏是一样的。
ADD_DEFINITIONS(-DQ_SYS_NAME=${CSYS_PRIVATE})
ADD_DEFINITIONS(-DQ_BUILD_TYPE=${BUILD})
